#include <stdio.h>
#include <malloc.h>
#include <string.h>

#include "file_process.h"
#include "list.h"

struct command * create_cmd(int server_id, int cmd_id, char *c){
	struct command *cmd;
	cmd = (struct command *)malloc(sizeof(struct command));
	cmd->cmd_type = 0x01;
	cmd->server_id = server_id;
	cmd->cmd_id = cmd_id;
	memcpy(cmd->cmd,c,strlen(c));
	return cmd;
}
/*
int main(){
	int st ;
	struct command *cmd;
	st = rcv_cmd(create_cmd(2,6,"6"));
	st = rcv_cmd(create_cmd(2,4,"4"));
	printf("%d\n",st);
	st = rcv_cmd(create_cmd(2,5,"5"));
	printf("%d\n",st);
	st = rcv_cmd(create_cmd(2,7,"7"));
  printf("%d\n",st);
	st = rcv_cmd(create_cmd(2,8,"8"));
	printf("%d\n",st);
	st = rcv_cmd(create_cmd(2,1,"1"));
	printf("%d\n",st);
	st = rcv_cmd(create_cmd(2,3,"33"));
	printf("%d\n",st);
	st = rcv_cmd(create_cmd(2,6,"6"));
	printf("%d\n",st);
	st = rcv_cmd(create_cmd(2,2,"e2"));
	printf("%d\n",st);

  print_all_cmd();
	return 0;
}
*/


int main(){
	char buff[BUF_SIZE];
	buff[0] = 0x01;
	buff[1] = 5;
	int server_id = 32;
	int min_seq_id = 2;
	int max_rcv_id  =31;

	bzero(buff+2,sizeof(buff)-2);
	memcpy(buff+2, &server_id, sizeof(int));
	memcpy(buff+2+sizeof(int), &min_seq_id, sizeof(int));
	memcpy(buff+2+2*sizeof(int), &max_rcv_id, sizeof(int));

	printf("type:%d\n",buff[0]);
	printf("server_count:%d\n",buff[1]);
	printf("server_id:%d\n",*(buff+2));
	printf("min_seq_id:%d\n",*(buff+2+sizeof(int)));
	printf("max_rcv_id:%d\n",*(buff+2+2*sizeof(int)));

	return 0;
}
